import React, { useEffect } from 'react'
import { getTrain } from '../../api'
import './Trainlist.css'

function Trainlist() {
  const [train, setTrain] = React.useState<any[]>([])
  useEffect(() => {
    getTrain().then(res => {
      console.log(res);
      setTrain(res.data.data)
    })
  }, [])
  return (
    <div>
      {
        train.map(item => {
          return <div key={item.id} className='train'>
            <div>{item.startPosition}</div>
            <div>{item.endPosition}</div>
          </div>
        })
      }
    </div>
  )
}

export default Trainlist
